package nx.behaviors;

/**
 * The Base class for all behaviors. This API implements potential fields for
 * navigation. That is why the Vector2d class of the nx.utils package is extensively
 * used. Remember to use also the arbiters located at the nx.arbitrators folder.
 * 
 * @author Alejandro Pustowka
 */
public abstract class NxBehavior {

    /**
     * The gain for the output of this behavior. Should be a value between 0 and 1.
     */
    private float gain = 1;

    /**
     * A behavior can be disabled or enabled.
     */
    public boolean enabled = true;

    /**
     * Each behavior has a particular name.
     */
    public String name;


    public int priority = 100;
    /**
     * Constructor.
     * @param name Name of the behavior, useful to identify it in arbiters.
     */
    public NxBehavior(String name) {
        this.name = name;
    }

    /**
     * Set function for gain.
     * @param gain Value of the gain of the behavior. Values permited are between 0 and 1.
     */
    public void setGain(float gain)
    {

        if(gain >= 0 && gain <= 1)
            this.gain = gain;
    }

    /**
     * Get function for gain.
     * @return The gain of this behavior.
     */
    public float getGain(){
        return gain;
    }

    /**
     * Set function for priority.
     * @param priority Value of the priority of the behavior. Values permited are between 0 and 100.
     */
    public void setPriority(int priority)
    {
        if(priority >= 0 && priority <= 100)
            this.priority = priority;
    }

    /**
     * Get function for priority.
     * @return The priority of this behavior.
     */
    public int getPriority()
    {
        return this.priority;
    }

    /**
     * This API implements potential fields,that is why it is vital that each
     * Behavior returns a Vector in 2D as its result.
     * @return The returned value of the behavior.
     */
    public abstract Object Value();

}
